using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Itdavany;
using Itdavany.Objects;
using Itdavany.Data;
using Itdavany.Utility;

namespace RollingKitty.Objects
{
    // A layer of image
    class TexturedPane : GameObject
    {
        private Texture2D skin;
        private Vector2 pos;
        private byte alpha;

        public TexturedPane()
            : base()
        {
            this.skin = null;
            this.pos = Vector2.Zero;
            this.alpha = byte.MaxValue;
        }

        public TexturedPane(string skin)
            : base()
        {
            this.Skin = skin;
            this.pos = Vector2.Zero;
            this.alpha = byte.MaxValue;
        }

        public TexturedPane(string skin, byte alpha)
        {
            this.Skin = skin;
            this.pos = Vector2.Zero;
            this.alpha = alpha;         
        }

        public TexturedPane(string skin, float x, float y)
            : base()
        {
            this.Skin = skin;
            this.pos = new Vector2(x, y);
            this.alpha = byte.MaxValue;
        }

        public TexturedPane(string skin, float x, float y, byte alpha)
            : base()
        {
            this.Skin = skin;
            this.pos = new Vector2(x, y);
            this.alpha = alpha;
        }

        public TexturedPane(string skin, Vector2 pos)
        {
            this.Skin = skin;
            this.pos = pos;
            this.alpha = byte.MaxValue;
        }

        public TexturedPane(string skin, Vector2 pos, byte alpha)
        {
            this.Skin = skin;
            this.pos = pos;
            this.alpha = alpha;
        }

        public string Skin
        {
            set
            {
                skin = null;
                if (value != "")
                    skin = Shared.ContentManager.Load<Texture2D>(value);
           
            }
        }

        public override void Draw()
        {
            if (skin != null && !IsHidden)
            {
                DefaultSpriteBatch.Begin(SpriteBlendMode.AlphaBlend);
                DefaultSpriteBatch.Draw(skin, pos, new Color(
                    byte.MaxValue, byte.MaxValue, byte.MaxValue, alpha));
                DefaultSpriteBatch.End();
            }

            base.Draw();
        }
    }
}
